class CGameWorld;
class CGameWorldEvent;
class CGamePlayer;
enum EKeyboardButtonID;
struct mesg_cpacket;

namespace AVUI
{
    class ListBox;
    class TextBox;
}

class CChatList
{
public:
    CChatList(CGameWorld* pGameWorld, AVUI::ListBox* pListbox, AVUI::TextBox* pTextbox);
    ~CChatList();

    void AddChat(const mesg_spacket* pChat);
    void OnGameWorldEvent(CGameWorldEvent* pEvent);

    bool HandleKeyPressed(EKeyboardButtonID eKeyboardButtonID);
private:
    void ClearAndDeactivate();
    bool InitMesgPacketFromText(mesg_cpacket* pPacket, const char* szChat);

    bool ChatTextAccepted();
    const char* GetChatIdentifierPosition(const char** rgszIdentifiers, int cIdentifiers, const char* szText);
    void InitMesgPacket(EMessageGroupFlags eGroup, char chWhoSentTo, const char* szText, mesg_cpacket* pPacket);
    bool IsShoutMessage(const char* szChat);
    bool IsTellMessage(const char* szChat);
    bool IsTeamMessage(const char* szChat);

    bool HandleShoutMessage(const char* szChat, mesg_cpacket* pPacket);
    bool HandleTellMessage(const char* szChat, mesg_cpacket* pPacket);
    bool HandleTeamMessage(const char* szChat, mesg_cpacket* pPacket);
    const char* GetTeamIdentifierPosition(const char* szChat, ETeamID* peTeamID);
    bool HandlePlayerMessage(const char* szChat, mesg_cpacket* pPacket);

    void OnEditKeyDown(AVUI::Object* pSender, AVUI::KeyEventArgs* pArgs);

    CGameWorld* m_pGameWorld;
    AVUI::ListBox* m_pList;
    AVUI::TextBox* m_pEditbox;
    CGameWorld::CEventSubscription* m_pEventSubscription;

    bool m_fReturnActivated;

    static const int c_maxChatMessages = 200;
};

